package com.justnow.offer;

/**
 * @author justnow
 * Created on 2020-09-25
 * Description
 */
public class Solution66 {
    public int[] constructArr(int[] a) {
        if (a == null || a.length <= 0) {
            return new int[0];
        }
        int length = a.length;
        int[] left = new int[length];
        int[] right = new int[length];
        int[] res = new int[length];
        left[0] = 1;
        right[length - 1] = 1;
        for (int i = 1; i < length; i++) {
            left[i] = left[i - 1] * a[i - 1];
            right[length - i - 1] = right[length - i] * a[length - i];
        }
        for (int i = 0; i < length; i++) {
            res[i] = left[i] * right[i];
        }
        return res;
    }
}
